<!DOCTYPE html>
<html lang="zh">
{include file="public/head"}
<link rel="stylesheet" type="text/css" href="/static/admin/js/webuploader/webuploader.css">
<body>
<div class="container-fluid">
  
  <div class="row">
    
    <div class="col-lg-12">
      <div class="card">
        <header class="card-header"><div class="card-title">个人信息</div></header>
        <div class="card-body">
        <form class="site-form" id="common_form" action="/admin/admin/adminInfo" method="post">
          <div class="d-flex">
            {empty name="admin_info.avatar"}
            <img src="/static/admin/images/default_avatar.jpeg" class="rounded-circle me-3 show_upload_file" style="width: 120px;height: 120px">
            <input type="hidden" name="avatar" class="file_path_value" value="/static/admin/images/default_avatar.jpeg">
            {else /}
            <img src="{$admin_info.avatar}" class="rounded-circle me-3 show_upload_file" style="width: 120px;height: 120px">
            <input type="hidden" name="avatar" class="file_path_value" value="{$admin_info.avatar}">
            {/empty}

            <div>
                <div class="filePicker">上传图片</div>
                <button type="button" class="btn btn-success" onclick="openLayer('选择图片', '/admin/common/selectImage')">选择图片</button>
            </div>

          </div>
          <hr>
            <div class="mb-3">
              <label for="username">用户名</label>
              <input type="text" class="form-control" name="username" id="username" value="{$admin_info.username}" disabled="disabled">
            </div>
            <div class="mb-3">
              <label for="phone">手机号</label>
              <input type="text" class="form-control" name="phone" id="phone" value="{$admin_info.phone}">
            </div>
            <div class="mb-3">
              <label for="phone">重置密码</label>
              <input type="text" class="form-control" name="password" id="password" placeholder="如果不修改密码，则不需要填写" value="">
              <small id="emailHelp" class="form-text text-muted">如果不修改密码，则不需要填写</small>
            </div>
            <button type="submit" class="btn btn-primary">保存</button>
          </form>
          
        </div>
      </div>
    </div>
        
  </div>
  
</div>
{include file="public/script"}
<script type="text/javascript" src="/static/admin/js/webuploader/webuploader.js"></script>
<script type="text/javascript">
var GUID = WebUploader.Base.guid();
// 初始化Web Uploader
var uploader = WebUploader.create({
    // 选完文件后，是否自动上传。
    auto: true,
    // swf文件路径
    swf: '/static/admin/js/webuploader/Uploader.swf',
    // 文件接收服务端。
    server: '/admin/common/chunkUpload',
    pick: {
        id:'.filePicker',
        //是否开启多个文件选择能力
        multiple:false,
    },
    chunked: true,   //开启分片上传
    chunkSize: 2*1024*1024,   //分片大小
    threads: 1,               //上传并发数。允许同时最大上传进程数。
    formData: {guid: GUID, is_chunk:1},   //guid：任务号
    //fileSingleSizeLimit:30*1024*1024,  //文件大小限制
    fileVal:'file',
    duplicate: true,  //可否可以重复上传相同文件（如果为true，则相同文件可以重复上传）
});
//上传成功时的回调方法
uploader.on('uploadSuccess',function (file,res) {
    if(res.code == 100)
    {
        $('.file_path_value').val(res.data.file_path);
        $('.show_upload_file').attr('src', res.data.file_path);
    }else{
        showNotify(res.msg, 'danger', 1000, 'mdi mdi-information-outline', 'top', 'right');
    }
})
uploader.on( 'uploadError', function( file ) {
    showNotify('上传文件失败', 'danger', 1000, 'mdi mdi-information-outline', 'top', 'right');
});
</script>
</body>
</html>